package com.md.controller;

import com.md.api.authentication.MacApi;
import com.md.application.service.users.MacApplicationService;
import com.md.model.po.Apis;
import com.md.model.po.Users;
import com.md.model.system.CommonResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 刘骄阳
 * 2022-04-01 18:28
 */
@RestController
@RequiredArgsConstructor
public class MacController implements MacApi {
  private final MacApplicationService macApplicationService;

  /**
   * 查询用户信息
   *
   * @param id 主键id
   * @return 操作结果
   */
  @Override
  public CommonResult<Users> queryUsersInfo(final Long id) {
    return macApplicationService.queryUsersInfo(id);
  }

  /**
   * 查询接口信息
   *
   * @param url 接口路径
   * @return 接口信息
   */
  @Override
  public CommonResult<Apis> queryApiInfo(final String url) {
    return macApplicationService.queryApiInfo(url);
  }

  /**
   * 查询是否有权限
   *
   * @param apiId  apiId
   * @param roleId 角色Id
   * @return 是否有权限
   */
  @Override
  public CommonResult<Boolean> queryHasAuth(final Long apiId, final Long roleId) {
    return macApplicationService.queryHasAuth(apiId, roleId);
  }
}
